home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 11
/
Mac Magazin and MacEasy Magazine CD - Issue 11.iso
/
Sharewarebibliothek
/
Entwickler
/
CDEF-DeBugger 2.0 ƒ
/
MyColor.c
< prev
next >
Wrap
Text File
|
1995-05-31
|
4KB
|
137 lines
// this is a set of simple procedures I use often when I color
// stuff. Nothing extremely difficult going on here. And I'm sure
// there is a better way of doing things, but like I said before
// I'm not the world's greatest programmer :)
// prototypes
void SetBackColor( short color );
void SetForeColor( short color );
void ColorNormal( void );
short GetDepth( CGrafPtr thePort );
void GetWinBackColor( WindowPtr theWindow, RGBColor *theColor );
void ConvertColor( short color, RGBColor *theColor );
void HiliteAndShadow( short hilite, short shadow, short var, Rect theRect );
/****************************************************************************
Sets the fore color with specified color from "MyColors.h"
*****************************************************************************/
void SetBackColor( short color )
{
RGBColor theColor;
theColor.red = theColor.green = theColor.blue = color;
RGBBackColor( &theColor );
}
/****************************************************************************
Sets the fore color with specified color from "MyColors.h"
*****************************************************************************/
void SetForeColor( short color )
{
RGBColor theColor;
theColor.red = theColor.green = theColor.blue = color;
RGBForeColor( &theColor );
}
/****************************************************************************
Sets the Color back to black and white
*****************************************************************************/
void ColorNormal( void )
{
RGBColor theColor;
theColor.red = theColor.green = theColor.blue = BLACK_COLOR;
RGBForeColor( &theColor );
theColor.red = theColor.green = theColor.blue = WHITE_COLOR;
RGBBackColor( &theColor );
}
/****************************************************************************
Find the depth of the control's port.
*****************************************************************************/
short GetDepth( CGrafPtr thePort )
{
if ( (*thePort).portVersion == ((short)0xC000) ) {
return (**(*thePort).portPixMap).pixelSize;
} else {
return 1;
}
}
/****************************************************************************
Finds the content color of a given window
*****************************************************************************/
void GetWinBackColor( WindowPtr theWindow, RGBColor *theColor )
{
AuxWinHandle auxWinHan;
if( GetAuxWin( theWindow, &auxWinHan ) ) {
// position 0 is the window's content color
*theColor = (**(**auxWinHan).awCTable).ctTable[0].rgb;
}
}
/****************************************************************************
Converts one of our predifened colors (MyColors.h) to a real RGBColor
*****************************************************************************/
void ConvertColor( short color, RGBColor *theColor )
{
(*theColor).red = (*theColor).green = (*theColor).blue = color;
}
/****************************************************************************
Just a quick utility that will draw a hilite and shadow on
a given rectangle. The variable will indicate if you draw it
extruded in or out.
extrudeIn = 0 // located in MyColors.h
extrudeOut = 1
*****************************************************************************/
void HiliteAndShadow( short hilite, short shadow, short var, Rect theRect )
{
InsetRect( &theRect, 1, 1 );
if( var == extrudeOut ) {
SetForeColor( hilite );
MoveTo( theRect.left + 1, theRect.bottom - 1 );
LineTo( theRect.right - 1, theRect.bottom - 1 );
LineTo( theRect.right - 1, theRect.top + 1 );
SetForeColor( shadow );
MoveTo( theRect.left, theRect.bottom - 2 );
LineTo( theRect.left, theRect.top );
LineTo( theRect.right - 2, theRect.top );
} else {
SetForeColor( shadow );
MoveTo( theRect.left + 1, theRect.bottom - 1 );
LineTo( theRect.right - 1, theRect.bottom - 1 );
LineTo( theRect.right - 1, theRect.top + 1 );
SetForeColor( hilite );
MoveTo( theRect.left, theRect.bottom - 2 );
LineTo( theRect.left, theRect.top );
LineTo( theRect.right - 2, theRect.top );
}
InsetRect( &theRect, -1, -1 );
ColorNormal();
}